package leetcode_core.leetcode_4;

import java.util.HashMap;
import java.util.Map;

/**
 * 功能描述
 *
 * @author: 张庭杰
 * @date: 2022年11月08日 14:54
 */
public class CountConsistentStrings {
    public int countConsistentStrings(String allowed, String[] words) {
        //设计一个map
        Map<Character,Boolean> need = new HashMap<>();
        int length = allowed.length();
        for(int i = 0;i < length;i++){
            need.put(allowed.charAt(i),true);
        }
        int cnt = 0;
        for (String word : words) {
            int len  = word.length();
            int j  = 0;
            for(;j < len;j++){
                if(need.get(word.charAt(j))!=null){
                    continue;
                }else{
                    break;
                }
            }
            if(j == len){
                cnt++;
            }
        }
        return cnt;
    }
}
